﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class SiteMaster : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)
        {
            ChangeLanguage("vi-VN");
        }
    }
    protected void vi_Click(object sender, ImageClickEventArgs e)
    {
        ChangeLanguage("vi-VN");
        Response.Redirect(Request.Path);
    }
    protected void en_Click(object sender, ImageClickEventArgs e)
    {
        ChangeLanguage("en-US");
        Response.Redirect(Request.Path);
    }
    public void ChangeLanguage(string culture)
    {
        var httpCookie = Request.Cookies["language"];
        if (httpCookie != null)
        {
            var cookie = Response.Cookies["language"];
            if (cookie != null) cookie.Value = culture;
        }
    }
}
